---
title: "Grid Column Start / End"
# description: "Utilities for controlling how elements are sized and placed across grid columns."
description: "用于控制在网格列中元素的大小和放置方式的功能类。"
---

import gridColumnPlugin from 'tailwindcss/lib/plugins/gridColumn'
import gridColumnStartPlugin from 'tailwindcss/lib/plugins/gridColumnStart'
import gridColumnEndPlugin from 'tailwindcss/lib/plugins/gridColumnEnd'
import { Disabling } from '@/components/Disabling'

export const classes = {
  plugin: [gridColumnPlugin, gridColumnStartPlugin, gridColumnEndPlugin]
}

<!-- ## Spanning columns -->
## 跨列

<!-- Use the `col-span-{n}` utilities to make an element span _n_ columns. -->
使用 `col-span-{n}` 功能类使元素跨越 _n_ 列。

```html purple
<template preview class="bg-white p-8">
  <div class="grid grid-cols-3 gap-4">
    <div class="bg-purple-300 h-12 rounded-md flex justify-center items-center text-white text-2xl font-extrabold">1</div>
    <div class="bg-purple-300 h-12 rounded-md flex justify-center items-center text-white text-2xl font-extrabold">2</div>
    <div class="bg-purple-300 h-12 rounded-md flex justify-center items-center text-white text-2xl font-extrabold">3</div>
    <div class="col-span-2 bg-purple-500 h-12 rounded-md flex justify-center items-center text-white text-2xl font-extrabold">4</div>
    <div class=" bg-purple-300 h-12 rounded-md flex justify-center items-center text-white text-2xl font-extrabold">5</div>
    <div class=" bg-purple-300 h-12 rounded-md flex justify-center items-center text-white text-2xl font-extrabold">6</div>
    <div class="col-span-2 bg-purple-500 h-12 rounded-md flex justify-center items-center text-white text-2xl font-extrabold">7</div>
  </div>
</template>

<div class="grid grid-cols-3 gap-4">
  <div class="...">1</div>
  <div class="...">2</div>
  <div class="...">3</div>
  <div class="**col-span-2** ...">4</div>
  <div class="...">5</div>
  <div class="...">6</div>
  <div class="**col-span-2** ...">7</div>
</div>
```

<!-- ## Starting and ending lines -->
## 起始与结束线

<!-- Use the `col-start-{n}` and `col-end-{n}` utilities to make an element start or end at the _nth_ grid line. These can also be combined with the `col-span-{n}` utilities to span a specific number of columns. -->
使用 `col-start-{n}` 和 `col-end-{n}` 功能类，使元素以第 n 条网格线为起点或终点。这些功能类也可以与 `col-span-{n}` 功能类结合使用，来跨越特定数量的列。

<!-- Note that CSS grid lines start at 1, not 0, so a full-width element in a 6-column grid would start at line 1 and end at line 7. -->
请注意，CSS 网格线从 1 开始，而不是 0，所以 6 列网格中的全宽元素将从第 1 条网格线开始，第 7 条网格线结束。

```html lightBlue
<template preview class="bg-white p-8">
  <div class="grid grid-cols-6 gap-4">
    <div class="bg-stripes bg-stripes-light-blue-500 bg-light-blue-300 bg-opacity-25 h-12 rounded-md flex items-center justify-center text-white text-2xl font-extrabold"></div>
    <div class="col-start-2 col-span-4 bg-light-blue-500 h-12 rounded-md flex items-center justify-center text-white text-2xl font-extrabold">1</div>
    <div class="bg-stripes bg-stripes-light-blue-500 bg-light-blue-300 bg-opacity-25 h-12 rounded-md flex items-center justify-center text-white text-2xl font-extrabold"></div>
    <div class="col-start-1 col-end-3 bg-light-blue-500 h-12 rounded-md flex items-center justify-center text-white text-2xl font-extrabold">2</div>
    <div class="bg-stripes bg-stripes-light-blue-500 bg-light-blue-300 bg-opacity-25 h-12 rounded-md flex items-center justify-center text-white text-2xl font-extrabold"></div>
    <div class="bg-stripes bg-stripes-light-blue-500 bg-light-blue-300 bg-opacity-25 h-12 rounded-md flex items-center justify-center text-white text-2xl font-extrabold"></div>
    <div class="col-end-7 col-span-2 bg-light-blue-500 h-12 rounded-md flex items-center justify-center text-white text-2xl font-extrabold">3</div>
    <div class="col-start-1 col-end-7 bg-light-blue-500 h-12 rounded-md flex items-center justify-center text-white text-2xl font-extrabold">4</div>
  </div>
</template>

<div class="grid grid-cols-6 gap-4">
  <div class="**col-start-2** col-span-4 ...">1</div>
  <div class="**col-start-1 col-end-3** ...">2</div>
  <div class="**col-end-7 col-span-2** ...">3</div>
  <div class="**col-start-1 col-end-7** ...">4</div>
</div>
```

<!-- ## Responsive -->
## 响应式

<!-- To control the column placement of an element at a specific breakpoint, add a `{screen}:` prefix to any existing grid-column utility. For example, use `md:col-span-6` to apply the `col-span-6` utility at only medium screen sizes and above. -->
要在特定的断点处控制元素列的放置方式，可以在任何现有的 grid-column 功能类前添加 `{screen}:` 前缀。例如，使用 `md:col-span-6` 来仅在中等尺寸及以上的屏幕上应用 `col-span-6` 功能类。

```html
  <div class="col-span-2 **md:col-span-6**"></div>
```

<!-- For more information about Tailwind's responsive design features, check out the [Responsive Design](/docs/responsive-design) documentation. -->
关于 Tailwind 的响应式设计功能的更多信息，请查看 [响应式设计](/docs/responsive-design) 文档。

<!-- ## Customizing -->
## 定制

<!-- By default Tailwind includes grid-column utilities for working with grids with up to 12 columns. You change, add, or remove these by customizing the `gridColumn`, `gridColumnStart`, and `gridColumnEnd` sections of your Tailwind theme config. -->
默认情况下，Tailwind 包括 grid-column 功能，用于处理最多有12个列的网格。您可以通过定制您的 Tailwind 主题配置的 `gridColumn`、 `gridColumnStart` 和 `gridColumnEnd` 部分来改变、添加或删除它们。

<!-- For creating more `col-{value}` utilities that control the `grid-column` shorthand property directly, customize the `gridColumn` section of your Tailwind theme config: -->
为了创建更多的 `col-{value}` 功能类来直接控制 `grid-column` 简写属性，请自定义 Tailwind 主题配置的 `gridColumn` 部分。

```diff-js
  // tailwind.config.js
  module.exports = {
    theme: {
      extend: {
        gridColumn: {
+         'span-16': 'span 16 / span 16',
        }
      }
    }
  }
```

<!-- We use this internally for our `col-span-{n}` utilities. Note that since this configures the `grid-column` shorthand property directly, we include the word `span` directly in the value name, it's _not_ baked into the class name automatically. That means you are free to add entries that do whatever you want here — they don't just have to be `span` utilities. -->
我们在内部将其用于 `col-span-{n}` 功能。请注意，因为这直接配置了 `grid-column` 速记属性，所以我们直接在值名中包含了 `span` 这个词，而_不是_自动加入到类名中。这意味着您可以自由地添加您想做的任何事情--它们不只是 `span` 功能。

<!-- To add new `col-start-{n}` utilities, use the `gridColumnStart` section of your Tailwind theme config: -->
要添加新的  `col-start-{n}` 功能类，请使用 Tailwind 主题配置的 `gridColumnStart` 部分。

```diff-js
  // tailwind.config.js
  module.exports = {
    theme: {
      extend: {
        gridColumnStart: {
+         '13': '13',
+         '14': '14',
+         '15': '15',
+         '16': '16',
+         '17': '17',
        }
      }
    }
  }
```

<!-- To add new `col-end-{n}` utilities, use the `gridColumnEnd` section of your Tailwind theme config: -->
要添加新的  `col-end-{n}` 功能类，请使用 Tailwind 主题配置的 `gridColumnEnd` 部分。

```diff-js
  // tailwind.config.js
  module.exports = {
    theme: {
      extend: {
        gridColumnEnd: {
+         '13': '13',
+         '14': '14',
+         '15': '15',
+         '16': '16',
+         '17': '17',
        }
      }
    }
  }
```

<!-- Learn more about customizing the default theme in the [theme customization documentation](/docs/theme#customizing-the-default-theme). -->
在 [主题自定义文档](/docs/theme#customizing-the-default-theme) 中了解更多关于自定义默认主题的信息。

<!-- ### Variants -->
### 变体

<!-- By default, only responsive variants are generated for grid-column utilities. -->
默认情况下，只为 grid-column 功能生成响应式变体。

<!-- You can control which variants are generated for the grid-column utilities by modifying the `gridColumn`, `gridColumnStart`, and `gridColumnEnd` properties in the `variants` section of your `tailwind.config.js` file. -->
您可以通过修改 `tailwind.config.js` 文件中 `variants` 部分的 `gridColumn`、`gridColumnStart` 和 `gridColumnEnd` 属性来控制为 grid-column 功能生成哪些变体。

```diff-js
  // tailwind.config.js
  module.exports = {
    variants: {
      // ...
+     gridColumn: ['responsive', 'hover'],
+     gridColumnStart: ['responsive', 'hover'],
+     gridColumnEnd: ['responsive', 'hover'],
    }
  }
```

<!-- Learn more about configuring variants in the [configuring variants documentation](/docs/configuring-variants/). -->
在 [配置变体文档](/docs/configuring-variants/) 中了解更多关于配置变体的信息。

### 禁用

<Disabling plugin={['gridColumn', 'gridColumnStart', 'gridColumnEnd']} name="grid-column" />
